<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增文章')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-article-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label">文章类型：</label>
                <div class="col-sm-8">
                    <select id="articleTypeId" name="articleTypeId" class="form-control select2-multiple">
                        <option th:each="type:${articleTypes}" th:value="${type.id}" th:text="${type.name}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">文章标题：</label>
                <div class="col-sm-8">
                    <input name="articleTitle" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">文章信息：</label>
                <div class="col-sm-8">
                    <textarea name="articleInfo" class="form-control" required></textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">文章内容：</label>
                <div class="col-sm-8">
                    <textarea name="articleContent" class="form-control" required></textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">发布时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input name="articlePublishTime" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">文章来源：</label>
                <div class="col-sm-8">
                    <select name="articleFrom" class="form-control" required>
                        <option value="0">原创</option>
                        <option value="1">转载</option>
                    </select>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: select2-js" />
    <script type="text/javascript">
        var prefix = ctx + "blog/article"
        $("#form-article-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-article-add').serialize());
            }
        }

        $("input[name='articlePublishTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $(function() {
            $('#articleTypeId').select2({
                placeholder:"请选择文章类型",
                allowClear: true
            });
        })
    </script>
</body>
</html>